_init() {
this._level = 0;
+ this._maxLevel = 100;
let params = {
styleClass: 'level',
},
set level(value) {
- this._level = Math.max(0, Math.min(value, 100));
+ this._level = Math.max(0, Math.min(value, this._maxLevel));
this.setValue(this._level / 100);
+ },
+
+ get maxLevel() {
+ return this._maxLevel;
+ },
+
+ set maxLevel(value) {
+ this._maxLevel = Math.max(100, value);
+
+ this.setMaximumValue(this._maxLevel / 100);
}
});
}
},
+ setMaxLevel(maxLevel) {
+ if (maxLevel === undefined)
+ maxLevel = 100;
+ this._level.maxLevel = maxLevel;
+ },
+
show() {
if (!this._icon.gicon)
return;
this.actor.hide();
this.setLabel(null);
this.setLevel(null);
+ this.setMaxLevel(null);
},
_relayout() {
this._osdWindows.length = Main.layoutManager.monitors.length;
},
- _showOsdWindow(monitorIndex, icon, label, level) {
+ _showOsdWindow(monitorIndex, icon, label, level, maxLevel) {
this._osdWindows[monitorIndex].setIcon(icon);
this._osdWindows[monitorIndex].setLabel(label);
this._osdWindows[monitorIndex].setLevel(level);
+ this._osdWindows[monitorIndex].setMaxLevel(maxLevel);
this._osdWindows[monitorIndex].show();
},
- show(monitorIndex, icon, label, level) {
+ show(monitorIndex, icon, label, level, maxLevel) {
if (monitorIndex != -1) {
for (let i = 0; i < this._osdWindows.length; i++) {
if (i == monitorIndex)
- this._showOsdWindow(i, icon, label, level);
+ this._showOsdWindow(i, icon, label, level, maxLevel);
else
this._osdWindows[i].cancel();
}
} else {
for (let i = 0; i < this._osdWindows.length; i++)
- this._showOsdWindow(i, icon, label, level);
+ this._showOsdWindow(i, icon, label, level, maxLevel);
}
},
let monitorIndex = params['monitor'] || -1;
let label = params['label'] || undefined;
let level = params['level'] || undefined;
+ let maxLevel = params['max_level'] || undefined;
let icon = null;
if (params['icon'])
icon = Gio.Icon.new_for_string(params['icon']);
- Main.osdWindowManager.show(monitorIndex, icon, label, level);
+ Main.osdWindowManager.show(monitorIndex, icon, label, level, maxLevel);
},
FocusApp(id) {